import request from '@/util/request'

/**
 * 创建订单
 * @param {Object} data - 订单数据
 * @param {string} data.attractionId - 景点ID
 * @param {number} data.ticketCount - 门票数量
 * @param {string} data.visitDate - 游玩日期
 * @param {Object} data.contact - 联系人信息
 * @param {string} data.contact.name - 联系人姓名
 * @param {string} data.contact.phone - 联系人手机号
 * @param {number} data.totalAmount - 总金额
 */
export const createOrder = (data) => {
  return request({
    url: '/api/order/create',
    method: 'post',
    data
  })
}

/**
 * 支付订单
 * @param {string} orderId - 订单ID
 */
export const payOrder = (orderId) => {
  return request({
    url: `order/${orderId}/pay`,
    method: 'post'
  })
}

/**
 * 获取订单详情
 * @param {string} orderId - 订单ID
 */
export const getOrderDetail = (orderId) => {
  return request({
    url: `order/${orderId}`,
    method: 'get'
  })
}

/**
 * 获取订单列表
 * @param {Object} params - 查询参数
 * @param {number} params.page - 页码
 * @param {number} params.pageSize - 每页数量
 * @param {string} params.status - 订单状态
 */
export const getOrderList = (params) => {
  return request({
    url: '/api/order/list',
    method: 'get',
    params
  })
}

/**
 * 取消订单
 * @param {string} orderId - 订单ID
 */
export const cancelOrder = (orderId) => {
  return request({
    url: `order/${orderId}/cancel`,
    method: 'post'
  })
}
